package com.xbkj.pgrp.server.model.app;

import com.xbkj.pgrp.server.dataproxy.ProjectDataProxy;
import lombok.Getter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.PreDataProxy;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.upms.model.base.HyperDataProxy;
import xyz.erupt.upms.model.base.HyperModel;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 项目信息
 */
@Erupt(
        name = "项目信息"
)
@Entity
@Table(name = "pgrp_project")
@PreDataProxy(ProjectDataProxy.class)
@Getter
public class Project extends HyperModel {
    @EruptField(
            views = @View(title = "项目名称", width = "200px"),
            edit = @Edit(title = "项目名称", notNull = true, search = @Search(vague = true))
    )
    @Column(nullable = false, length = 512)
    private String projectName;

    @EruptField(
            views = @View(title = "计划开始时间"),
            edit = @Edit(title = "计划开始时间", notNull = true, type = EditType.DATE)
    )
    private Date originBeginDate;

    @EruptField(
            views = @View(title = "计划结束时间"),
            edit = @Edit(title = "计划结束时间", notNull = true, type = EditType.DATE)
    )
    private Date originEndDate;

    @EruptField(
            views = @View(title = "项目描述"),
            edit = @Edit(title = "项目描述", notNull = true,type = EditType.TEXTAREA)
    )
    @Column(nullable = false, length = 2056)
    private String projectDesc;

    @OneToMany
    @EruptField(
            views = @View(title = "项目里程碑信息"),
            edit = @Edit(title = "项目里程碑信息", type = EditType.TAB_TABLE_ADD)
    )
    @JoinColumn(name = "project_id")
    private Set<MileStone> mileStones;

    @OneToMany
    @EruptField(
            views = @View(title = "项目资源信息"),
            edit = @Edit(title = "项目资源信息", type = EditType.TAB_TABLE_ADD)
    )
    @JoinColumn(name = "project_id")
    private Set<ProjectResource> projectResources;
}
